<template>
  <div class="home">
    <el-row :gutter="20">
      <el-col :span="6">
        <el-card shadow="hover">
          <template #header>
            <div class="card-header">
              <span>总用户数</span>
            </div>
          </template>
          <div class="card-body">
            <el-statistic :value="statistics.userCount">
              <template #prefix>
                <el-icon><User /></el-icon>
              </template>
            </el-statistic>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card shadow="hover">
          <template #header>
            <div class="card-header">
              <span>总订单数</span>
            </div>
          </template>
          <div class="card-body">
            <el-statistic :value="statistics.orderCount">
              <template #prefix>
                <el-icon><List /></el-icon>
              </template>
            </el-statistic>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card shadow="hover">
          <template #header>
            <div class="card-header">
              <span>总商品数</span>
            </div>
          </template>
          <div class="card-body">
            <el-statistic :value="statistics.productCount">
              <template #prefix>
                <el-icon><Goods /></el-icon>
              </template>
            </el-statistic>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card shadow="hover">
          <template #header>
            <div class="card-header">
              <span>总销售额</span>
            </div>
          </template>
          <div class="card-body">
            <el-statistic :value="statistics.totalSales" prefix="￥">
              <template #prefix>
                <el-icon><Money /></el-icon>
              </template>
            </el-statistic>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { User, List, Goods, Money } from '@element-plus/icons-vue'

const statistics = ref({
  userCount: 100,
  orderCount: 1000,
  productCount: 500,
  totalSales: 99999
})
</script>

<style scoped lang="scss">
.home {
  .el-row {
    margin-bottom: 20px;
  }
  
  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .card-body {
    text-align: center;
    
    .el-statistic {
      .el-icon {
        margin-right: 8px;
        font-size: 20px;
      }
    }
  }
}
</style>